<?php
namespace app\admin\controller;

use think\Db;

class Message extends Base{
      /*
       *  留言列表
       */
    public function index(){
        $list = Db::name('message')->order('add_time desc')->paginate(12);
        $this->assign('list', $list);
        return $this->fetch();
    }
       /*
        *删除留言
        */
    public function delMessage(){
        if(IS_AJAX){
            $id = I('get.id');
            if(empty($id)){
                $data = array('status' => 0, 'msg' => '该留言不存在！');
            }
            $result = Db::name('message')->where(array('id' => $id))->delete();

             $data = $result ? array('status' => 1, 'msg' => '删除成功')
                            : array('status' => 0, 'msg' => '删除失败');

                       return ajaxReturn($data);
        }
    }
}
